package com.cn.crypt;

import com.cn.xc.utils.StringUtil;

/**
 * FUN:
 * 
 * @author sushy
 * @date 2016-3-23
 */
public class SHACryption {
	public String EncryptSHA(String strPwd) {
		String strEncrypted = "";
		try {
			byte[] shaKeyBytes = { (byte) 0xA3, (byte) 0x35, (byte) 0x48, (byte) 0x2A, (byte) 0x21, (byte) 0x24,
					(byte) 0x83, (byte) 0xE6, (byte) 0xBF, (byte) 0xB3, (byte) 0x72, (byte) 0xF8, (byte) 0x41,
					(byte) 0xDF, (byte) 0x0C, (byte) 0xCB };

			java.security.MessageDigest alga = java.security.MessageDigest.getInstance("SHA-1");

			alga.update(shaKeyBytes);
			alga.update(strPwd.getBytes());
			alga.update(shaKeyBytes);
			byte[] digesta = alga.digest();
			strEncrypted = StringUtil.byte2hex(digesta);
			//# System.out.println(strPwd+" SHA加密后十六进制字符串为:" + strEncrypted);
		} catch (Exception ex) {
			ex.printStackTrace();
			System.out.println("SHA加密字符串失败");
		}
		return strEncrypted;
	}

}
